vue.js 引用背景图 background 无效的3种解决办法

您所在的位置:网站首页 background image属性值无效 vue.js 引用背景图 background 无效的3种解决办法

vue.js 引用背景图 background 无效的3种解决办法

#vue.js 引用背景图 background 无效的3种解决办法| 来源: 网络整理| 查看: 265

#vue.js项目中,出现css调用background背景图无效?如何解决?

或者调用标签,也无效果? 直接上代码,自行对比查找一下:

效果图预览:

效果图

1. 正确的代码,示例如下: import Bg2 from '@/../static/images/logo2.png' export default { name: 'App', data () { return { bg2: Bg2, } } } .demo{width: 100px;margin: 50px auto;} .img1{ width: 100px; height: 100px; background: url('~@/../static/images/logo1.png') center center no-repeat; background-size: 100px auto; } .img2{ width: 100px; height: 100px; background-position: center center; background-repeat: no-repeat; background-size: 100px auto; } 上述代码中,出现了诸如:~@/和 @/,如果删除后,测试效果也正常,你也可以都去掉,不影响。 2. 错误的代码,截图对比,如下:

错误的代码演示

报错结果截图如下:

错误代码演示的结果:报错

修改为正确代码方法,类比如下:


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3